import axios from 'axios'

// axios.defaults.baseURL = 'http://222.20.81.82:9000/'; //奉泽贤
// axios.defaults.baseURL = 'http://222.20.81.173:9000/'; //苏新宇
axios.defaults.baseURL = 'http://222.20.81.236:9000/'; //闵力
// axios.defaults.baseURL = 'http://47.106.131.190:8080/';  // 部署
// axios.defaults.baseURL = 'http://47.111.144.250:9000/'; // 阿里云部署
// axios.defaults.baseURL = 'http://rap2api.taobao.org/app/mock/161878'    //张雷 测试接口

//登录
export const login = params => {
    return axios.post('/NB/Login', params)
};

/**
 * 水司设置
 */
// 基本设置
// 更新基本信息
export const updateBasicInfo = params => {
    return axios.post('/NB/updateCronAndType', params)
};
// 微信账户设置
export const updateWechatInfo = params => {
    return axios.post('/NB/wxConfig', params)
};
// 获取水价信息
export const getPriceInfo = params => {
    return axios.post('/NB/GetPriceInfoByEnprNo', params)
};
// 更新水价信息
export const updatePriceInfo = params => {
    return axios.post('/NB/UpdateChargeLevelInfo', params)
};
// 获取固定水价
export const getFixedPriceInfo = params => {
    return axios.post('/NB/GetFixedPriceInfoByEnprNo', params)
};
// 更新固定水价信息
export const updateFixedPriceInfo = params => {
    return axios.post('/NB/UpdateFixedPriceInfoByEnprNoAndUserType', params)
};

/**
 * 抄表管理
 */
/**
 * 基础数据
 */
// 获取区域
export const getRegion = params => {
    return axios.post('/NB/GetRegionInfo', params)
};
// 获取小区Id
export const getCommunityId = params => {
    return axios.post('/NB/GetCommunityInfoByRegion', params)
};
// 获取小区
export const getCommunity = params => {
    return axios.post('/NB/GetInfoByRegion', params)
};
// 创建区域
export const addRegion = params => {
    return axios.post('/NB/NB/addRegion', params)
};
// 创建小区
export const addCommunity = params => {
    return axios.post('/NB/NB/addCommunity', params)
};
// QBTT 检测文件
export const checkQBTTExcel = params => {
    return axios.post('/QBTT/QBT/checkQBTTExcel', params)
};
// QBTT 数据导入
export const importQBTTCheck = params => {
    return axios.post('QBTT/NB/importCheck', params)
};
// NB 检测文件
export const checkNBExcel = params => {
    return axios.post('/NB/checkNBFormat', params)
};
// NB 数据导入
export const importNBCheck = params => {
    return axios.post('/NB/nbImport', params)
};
// NB 出厂表导入
export const importNewDevice = params => {
    return axios.post('/NB/importNewDevice', params)
};
// NB 出厂表导入检测
export const checkNewDevice = params => {
    return axios.post('/NB/checkNBDevice', params)
};
// NB出厂表控制
export const controlNewDevice = params => {
    return axios.post('/NB/getCommandToDevice', params)
};
// NB水表数据更新
export const updateNewDevice = params => {
    return axios.post('/NB/updataNBDevice', params)
};
// NB出厂表删除
export const deleteNewDevice = params => {
    return axios.post('/NB/delectDeviceInit', params)
};
// NB表小区日用量
export const getCommDayUse = params => {
    return axios.post('/NB/getDayAmounts', params)
};
// NB表小区月用量
export const getCommMonthUse = params => {
    return axios.post('/NB/getMonthAmounts', params)
};
/**
 * 集抄器水表
 */
/**
 * 抄表状态
 */
export const meterReadingStatus = params => {
    return axios.post('QBTT/Center/searchCenter', params)
};
// 查看今日临时命令
export const getDayList = params => {
    return axios.post('QBTT/Command/getDayList', params)
};
// 查看今日失败命令
export const getFailedList = params => {
    return axios.post('QBTT/Command/getFailedList', params)
};
// 集中器下的采集器
export const getCollectionByCenterId = params => {
    return axios.post('QBTT/Center/getCollectionByCenterId', params)
};
// 查看所有表、查看采集器下的表
export const getDeviceList = params => {
    return axios.post('QBTT/Center/deviceListAll', params)
};
// 查看失败表
export const getFailedDeviceList = params => {
    return axios.post('QBTT/Center/findFailedDevice', params)
};
// 查看历史数据
export const QueryHistoryData = params => {
    return axios.post('QBTT/Device/QueryHistoryData', params)
};
// 数据采集至集中器
export const centerCollect = params => {
    return axios.post('QBTT/Center/centerCollect', params)
};
// 读取集中器数据
export const centerDataLoad = params => {
    return axios.post('QBTT/Center/centerDataLoad', params)
};
// 设备校验
export const check = params => {
    return axios.post('QBTT/Center/check', params)
};
// 下载用户档案
export const userDownload = params => {
    return axios.post('QBTT/Center/userDownload', params)
};
// 读取集中器信息
export const centerRead = params => {
    return axios.post('QBTT/Center/centerRead', params)
};
// 开阀
export const centerOpen = params => {
    return axios.post('QBTT/Center/centerOpen', params)
};
// 关阀
export const centerClose = params => {
    return axios.post('QBTT/Center/centerClose', params)
};
// 对水表发数据采集命令
export const tempCollect = params => {
    return axios.post('QBTT/Device/tempCollect', params)
};
// 对水表发数据读取命令
export const dataLoad = params => {
    return axios.post('QBTT/Device/dataLoad', params)
};
// 对水表发控制开阀命令
export const deviceOpen = params => {
    return axios.post('QBTT/Device/deviceOpen', params)
};
// 对水表发控制关阀命令
export const deviceClose = params => {
    return axios.post('QBTT/Device/deviceClose', params)
};
// 数据导出
export const exportByStatus = params => {
    return axios.post('QBTT/exportByStatus', params, {
        responseType: 'arraybuffer'
    })
};

/**
 * 定时抄表方案
 */
// 获取某水司下的定时抄表方案
export const getTimingMeterReadingScheme = params => {
    return axios.post('/QBTT/Command/ShowReadScheme', params)
};
// 添加定时抄表方案
export const addTimingMeterReadingScheme = params => {
    return axios.post('/QBTT/Command/AddReadScheme', params)
};
// 修改定时抄表方案
export const modifyTimingMeterReadingScheme = params => {
    return axios.post('/QBTT/Command/UpdateReadScheme', params)
};
// 删除定时抄表方案
export const deleteTimingMeterReadingScheme = params => {
    return axios.post('/QBTT/Command/DelReadScheme', params)
};

/**
 * 集抄器编辑
 */
// 获取水司下的区域
export const getAreaList = params => {
    return axios.post('/QBTT/areaList', params)
};
// 获取区域下的集中器及详细信息
export const getCenterList = params => {
    return axios.post('/QBTT/centerList', params)
};
// 获取单个集中器详细信息
export const searchEditCenter = params => {
    return axios.post('/QBTT/searchEditCenter', params)
};
// 修改集中器信息
export const modifyCenter = params => {
    return axios.post('/QBTT/saveEditCenter', params)
};
// 删除集中器
export const deleteCenter = params => {
    return axios.post('/QBTT/deleteCenter', params)
};
// 获取集中器下的采集器及详细信息
export const getCollectionList = params => {
    return axios.post('/QBTT/collectionList', params)
};
// 修改采集器信息
export const modifyCollection = params => {
    return axios.post('/QBTT/editCollection', params)
};
// 删除采集器
export const deleteCollection = params => {
    return axios.post('/QBTT/deleteCollection', params)
};

/**
 * 查询水表
 */
// 根据表编号查询
export const findByDeviceNo = params => {
    return axios.post('/QBTT/FindByDeviceNo', params)
};
// 根据用户性名查询
export const findByUserName = params => {
    return axios.post('/QBTT/FindByUserName', params)
};
// 根据用户编号查询
export const findByUserNo = params => {
    return axios.post('/QBTT/FindByUserNo', params)
};
// 修改表信息
export const modifyDevice = params => {
    return axios.post('/QBTT/EditDevice', params)
};
// 换表
export const changeDeviceQBT = params => {
    return axios.post('/QBTT/ChangeDevice', params)
};
// 删除表
export const deleteDevice = params => {
    return axios.post('/QBTT/DelDevice', params)
};

/**
 * 换表记录
 */
// 查看换表记录
export const getAllChangingRecord = params => {
    return axios.post('/QBTT/GetAllRecord', params)
};
// 删除换表记录
export const deleteChangingRecord = params => {
    return axios.post('/QBTT/DelChangeRecord', params)
};

/**
 * 故障诊断
 */
// 查看采集器下失败表
export const getCollectionFailedDevice = params => {
    return axios.post('/QBTT/Center/findCollectionFailedDevice', params)
};
// 查看水司下失败表
export const getEnprFailedDevice = params => {
    return axios.post('/QBTT/getDeviceError', params)
};

/**
 * 运营管理
 */
// 获取小区楼栋消息
export const getAreaInfo = params => {
    return axios.post('/NB/GetUserInfoByBlock', params)
};
// 根据areaId获取具体地址
export const getDeArea = params => {
    return axios.post('/NB/GetAddrInfoByBlock', params)
};
// 根据areaId和具体住址获取某个用户的信息
export const getUserByArea = params => {
    return axios.post('/NB/GetUserByBlockAndAddr', params)
};
// 根据表地址获取某个用户的信息
export const getBasicInfoByDeviceNo = params => {
    return axios.post('/NB/GetUserByAddrAndEnprNo', params)
};
// 根据userName获取某个用户的信息
export const getUserByUserName = params => {
    return axios.post('/NB/GetUserByNameAndEnprNo', params)
};
// 获取用户信息
export const getBasicInfo = params => {
    return axios.post('/NB/GetUserInfoByBlock', params)
};
// 获取单个用户信息
export const getUserDetailInfo = params => {
    return axios.post('/NB/GetUserById', params)
};
// 修改单个用户信息
export const modifyUserDetailInfo = params => {
    return axios.post('/NB/UpdateUserDetailInfo', params)
};
// 获取表详细信息
export const getDeviceDetailInfo = params => {
    return axios.post('/NB/GetDeviceInfo', params)
};
// NB 修改表详细信息
export const modifyDeviceDetailInfo = params => {
    return axios.post('/NB/UpdateDeviceDetailInfo', params)
};
// NB 换表功能
export const changeDevice = params => {
    return axios.post('/NB/ChangeDevice', params)
};
// 获取表读数历史记录
export const getHistoryData = params => {
    return axios.post('/NB/GetHistoryData', params)
};
// 获取表日用量历史数据
export const getDailyUse = params => {
    return axios.post('/NB/getDaycountPage', params)
};
// 按日期查询表日用量历史数据
export const searchDailyUseByDate = params => {
    return axios.post('/NB/GetDeviceInData', params)
};
// 按日期查询日水费历史数据
export const getDayCostByDate = params => {
    return axios.post('/NB/GetUserDaycostDetailInDate  ', params)
};
// 获取用户日水费数据
export const getDayCost = params => {
    return axios.post('/NB/GetUserDaycostDetail', params)
};
// 获取表月用量历史数据
export const getMonthCount = params => {
    return axios.post('/NB/getMonthcountPage', params)
};
// 获取表月用量历史数据2
export const getMonthCount2 = params => {
    return axios.post('/NB/GetDeviceMonthcount', params)
};
// 获取用户月总水费数据
export const getMonthCost = params => {
    return axios.post('/NB/getUserMonthcostPage', params)
};
// 获取月水费
export const getMonthCostData = params => {
    return axios.post('/NB/GetUserMonthcostDetail', params)
};
// 查询月水费
// export const getMonthCostDataByDate = params => {
//     return axios.post('/NB/...', params)
// };
// 用户存钱
export const saveMoney = params => {
    return axios.post('/NB/UpdateAccountBanlance', params)
};
// 微信支付
export const payByWechat = params => {
    return axios.post('/NB/order/wx', params)
};
// 存扣款明细
export const getDetailedCostHistory = params => {
    return axios.post('GetDetailedCostHistory', params)
};

// 用户反馈
// 反馈列表获取、查询、删除
export const getFeedbackList = params => {
    return axios.post('/NB/getFeedbackByEnprNo', params)
};
export const getCommunityFeedbackList = params => {
    return axios.post('/NB/getFeedbackByCommunityIdAndEnprNo', params)
};
export const getFeedbackByUserNo = params => {
    return axios.post('/NB/getFeedbackByUserNoAndEnprNo', params)
};
export const getFeedbackByDeviceNo = params => {
    return axios.post('/NB/getFeedbackByDeviceNoAndEnprNo', params)
};
export const deleteFeedback = params => {
    return axios.post('/NB/deleteFeedbackInfo', params)
};
// 获取完成时间
export const RepairFinish = params => {
    return axios.post('/NB/RepairFinish', params)
};
// 更新处理详情
export const updateProgress = params => {
    return axios.post('/NB/Repairman', params)
};

/* 通知公告 */
// 获取，发布，删除
export const getNotice = params => {
    return axios.post('/NB/getNotice', params)
};
export const putNotice = params => {
    return axios.post('/NB/inputNotice', params)
};
export const deleteNotice = params => {
    return axios.post('/NB/deleteNotice', params)
};
/**
 * NB水表
 */
// 水表出厂检测表
export const getMeterCheckList = params => {
    return axios.post('/NB/getAllDevice', params)
};
// 按小区显示水表信息
export const readingStatusByComm = params => {
    return axios.post('/NB/searchCenter', params)
};
// 获取小区所有表信息
export const getCommMeterList = params => {
    return axios.post('/NB/deviceList', params)
};
// 获取小区所有失败表信息
export const getFailedCommMeterList = params => {
    return axios.post('/NB/getFailDevice', params)
};
// 获取小区或水司故障表信息
export const getWarningDeviceList = params => {
    return axios.post('/NB/getWarningDevice', params)
};
// 按用户名、用户地址、表地址查询
export const getCommMeterByUserName = params => {
    return axios.post('/NB/getDeviceByUserName', params)
};
export const getCommMeterByUserAddr = params => {
    return axios.post('/NB/getDeviceByUserAddr', params)
};
export const getCommMeterByDeviceNo = params => {
    return axios.post('/NB/getDeviceByDeviceNo', params)
};

/**
 * 成员管理
 */
// 添加或修改管理员信息
export const addOrModifyOperator = params => {
    return axios.post('/NB/AddOrModifyOperator', params)
};
// 获取所有管理员信息
export const getOperatorList = params => {
    return axios.post('/NB/GetOperatorList', params)
};
// 删除管理员信息
export const deleteOperator = params => {
    return axios.post('/NB/DeleteOperator', params)
};

// 修改个人信息
export const updatePrivateInfo = params => {
    return axios.post('/NB/UpdatePrivateInfo', params)
};

// 水费管理
// 日、月账目
export const getAccountHistory = params => {
    return axios.post('GetAccountHistory', params)
};
// 日详细账目
export const dailyDetailAccount = params => {
    return axios.post('DailyDetailAccount', params)
};

// 报表输出
export const downloadInfo = (area, date) => {
    return axios.get('UserDataExport?area=' + area + '&date=' + date, {
        responseType: 'arraybuffer'
    })
};
// 根据小区名获取月份
export const getTimeByArea = params => {
    return axios.post('GetTimeByArea', params)
};

/**
 * 超级管理员特权
 */
// 水司管理
// 获取所有水司信息
export const getAllEnprMsg = params => {
    return axios.post('/NB/GetAllEnprMsg', params)
};
// 根据水司编码获取全部小区
export const getCommMsgByRnprNo = params => {
    return axios.post('/NB/GetCommunityInfo', params)
};
// 新增 / 修改水司
export const addOrModifyEnprMsg = params => {
    return axios.post('/NB/AddOrModifyEnprMsg', params)
};
// 删除水司
export const deleteEnprMsg = params => {
    return axios.post('/NB/DeleteEnprMsg', params)
};
// 用量导出
export const expDevice = params => {
    return axios.post('ExpDevice', params)
};
// 查看故障信息
export const getFaultData = params => {
    return axios.post('/NB/getDefaultAnalysis', params)
};


/**
 *  设备管理
 */
// 大用户水表状态
// 授权获取第三方 token
export const getToken = params => {
    return axios.post('/NB/bigDevice/bigDevice', params)
};
// 获取大表列表
export const getMeterList = params => {
    return axios.post('/NB/bigDevice/getBigDevice', params)
};
// 获取指定大表
export const getMeterData = params => {
    return axios.post('/NB/bigDevice/getRealData', params)
};
// 日用量统计
export const dayAnalysis = params => {
    return axios.post('/NB/bigDevice/dayAnalysis', params)
};
// 月用量统计
export const monthAnalysis = params => {
    return axios.post('/NB/bigDevice/monthAnalysis', params)
};
// 获取历史数据
export const getHistoryDataList = params => {
    return axios.post('/NB/bigDevice/getHistoryDataList', params)
};
// 获取通信日志
export const getCommLogList = params => {
    return axios.post('/NB/bigDevice/getCommLogList', params)
};
// 获取水质信息
export const getWaterQualityData = params => {
    return axios.post('/NB/bigDevice/outputWaterquality', params)
};

// 开户，过户，销户
export const setUserMsg = params => {
    return axios.post('/NB/CreateAccount', params)
};
export const changeUserMsg = params => {
    return axios.post('/NB/ReplaceAccount', params)
};
export const deleteUserMsg = params => {
    return axios.post('/NB/RemoveAccount', params)
};
